package b3.widget.home.top
{
	import b3.config.*;
	import b3.model.*;
	import b3.util.*;
	
	import com.greensock.*;
	
	import flash.display.Sprite;
	import flash.events.*;

	public class TopPane extends Sprite
	{
		private var storeIcon:StoreIcon;
		private var matchIcon:MatchIcon;
		private var rankIcon:RankIcon;
		private var guinnessIcon:GuinnessIcon;
		private var unionIcon:UnionIcon;
		private var hideFlag:Boolean;
		
		public function TopPane()
		{
			super();
			//商城
			storeIcon = new StoreIcon();
			storeIcon.x = -70;
			storeIcon.y = 70 - storeIcon.height;
			storeIcon.disableMouseOverTip();
			addChild(storeIcon);
			//比赛
			matchIcon = new MatchIcon();
			matchIcon.x = -140;
			matchIcon.y = 70 - matchIcon.height;
			matchIcon.disableMouseOverTip();
			addChild(matchIcon);
			//排行
			rankIcon = new RankIcon();
			rankIcon.x = -210;
			rankIcon.y = 70 - rankIcon.height;
			rankIcon.disableMouseOverTip();
			addChild(rankIcon);
			//吉尼斯
			guinnessIcon = new GuinnessIcon();
			guinnessIcon.x = -280;
			guinnessIcon.y = 70 - guinnessIcon.height;
			guinnessIcon.disableMouseOverTip();
			addChild(guinnessIcon);
			//联盟
			unionIcon = new UnionIcon();
			unionIcon.x = -350;
			unionIcon.y = 70 - unionIcon.height;
			unionIcon.disableMouseOverTip();
			addChild(unionIcon);
						
			this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			this.addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
		}
		
		public function hide():void
		{
			hideFlag = true;
			TweenLite.to(this, 1, {x: BFont.stageWidth + this.width + 70});
		}
		
		public function show():void
		{
			hideFlag = false;
			TweenLite.to(this, 1, {x: BFont.stageWidth});
		}
		
		private function onAddedToStage(event:Event):void
		{
			stage.addEventListener(Event.FULLSCREEN, onFullScreen);
			onFullScreen(null); 
		}

		private function onRemovedFromStage(event:Event):void
		{
			stage.removeEventListener(Event.FULLSCREEN, onFullScreen);
		}
		
		private function onFullScreen(event:Event):void
		{
			this.x = hideFlag ? BFont.stageWidth + this.width + 70 : BFont.stageWidth;
			this.y = BFont.stageHeight - 150;
		}
	}
}